﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Task03
{
    class Tree
    {
        private List<Tree> childs;
        public int Value;
        public List<Tree> Childs
        {
            get
            {
                if (childs == null)
                {
                    childs = new List<Tree>();
                }
                return childs;
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
			string input = Console.ReadLine();

			Tree tree = ReadTree(input);

            BFS(tree);
        }

		static Tree ReadTree(string input)
		{
			string substring = input.Substring(1, input.Length - 2);
			int index = 0;
			StringBuilder sb = new StringBuilder();
			while (char.IsDigit(substring[index]))
			{
				sb.Append(substring[index]);
				index++;
			}
			Tree tree = new Tree() { Value = int.Parse(sb.ToString()) };
			substring = substring.TrimStart("0123456789".ToCharArray());
			substring = substring.TrimStart("->".ToCharArray());

			List<string> branches = SplitBranches(substring);

			int leaf;
			foreach (var branch in branches)
			{
				if (int.TryParse(branch, out leaf))
				{
					tree.Childs.Add(new Tree() { Value = leaf });
				}
				else
				{
					tree.Childs.Add(ReadTree(branch));
				}
			}
			return tree;
		}

		static List<string> SplitBranches(string input)
		{
			List<string> split = new List<string>();
			int count = 0;
			StringBuilder sb = new StringBuilder();
			foreach (var ch in input)
			{
				if (ch == ',' && count == 0)
				{
					split.Add(sb.ToString());
					sb.Clear();
					continue;
				}
				sb.Append(ch);
				if (ch == '(')
				{
					count++;
				}
				if (ch == ')')
				{
					count--;
				}
			}
			split.Add(sb.ToString());
			return split;
		}

        private static void BFS(Tree node)
        {
            Queue<Tree> queue = new Queue<Tree>();
            queue.Enqueue(node);
            int leafs = 0;
            int nodes = 0;

            while (queue.Count > 0)
            {
                var nextNode = queue.Dequeue();
                if (nextNode.Childs.Count > 0)
                {
                    nodes++;
                }
                else
                {
                    leafs++;
                }

                foreach (var child in nextNode.Childs)
                {
                    queue.Enqueue(child);
                }
            }

			// removes the root
			nodes--;
            Console.WriteLine(nodes);
            Console.WriteLine(leafs);
        }
    }
}
